package org.soarsky.wealthchengdu.module.set;

import org.soarsky.wealthchengdu.R;
import org.soarsky.wealthchengdu.appliction.MyAppliction;
import org.soarsky.wealthchengdu.imageCache.CacheMemUtil;
import org.soarsky.wealthchengdu.language.LanguageUtil;
import org.soarsky.wealthchengdu.util.Config;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class SetActivity extends Activity {
	
	TextView setTv;//需要清理的内存大小数字
	RelativeLayout setRelative;//清除缓存点击按钮
	ImageView setTitleReturn;
	TextView setTitleTv;//设置界面Title字
	private LanguageUtil util;
	private String titleName;
	TextView setClean;
	Button collectBtn;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_set);
		intnView();
	}
	
	
	public void intnView(){
		util = Config.changeLanguage(MyAppliction.mCn);
		titleName = util.getSet();
		setTv=(TextView)findViewById(R.id.set_tv_number);
		collectBtn=(Button)findViewById(R.id.collect_btn);
		setRelative=(RelativeLayout)findViewById(R.id.set_relative);
		setTitleReturn=(ImageView)findViewById(R.id.title_iv_img);
		setTitleTv=(TextView)findViewById(R.id.title_tv_text);
		setClean=(TextView)findViewById(R.id.setclean);
		setTitleTv.setText(titleName);
		collectBtn.setText(util.getFavorite());
		setClean.setText(util.getClean());
		
		setRelative.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				CacheMemUtil.removeImages();
				setText(Config.languageUtil);
			}
		});
		setTitleReturn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				SetActivity.this.finish();
			}
		});
		collectBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent=new Intent(SetActivity.this,CollectActivity.class);
			    startActivity(intent);
			}
		});
	}
	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		setText(Config.languageUtil);
		MyAppliction.ifcollect=false;
	}
	
	public void setText(LanguageUtil util){
		setTv.setText(CacheMemUtil.getDirSize());
	}
}
